

********************************
***the analysis starts from here
********************************
clear
cd "C:\Users\Wei-hsin Yu\Box\PAPERS\publication\Elite college in Taiwan\study 2"
use  NTU2022_23.dta



*to select the first case from the department for analysis
**create id within department for all applicants 
sort year dept 學測應試號碼
*create serial id within department for all applincats 
bysort year dept  : gen did = _n
label var did "id within dept for all applicants" 

*create serial id within department for applicants who entered second round*
sort year dept dsource 學測應試號碼
bysort year dept dsource : gen did2 = _n 
replace did2 = . if dsource <3
label var did2 "id within dept for those who entered 2nd round"

**tab department 
bysort year: tab dept if did2==1 



**calculate number of dept applied by each student
sort year id dept
bysort year id: gen obsnumber=[_n-1]+1 
egen obsnomax=max(obsnumber), by (year id)
label var obsnomax "# of dept applied"

bysort year id dsource: gen obsnumber2=[_n-1]+1 if dsource==3
egen obsnomax2=max(obsnumber2) if dsource ==3, by (year id) 
label var obsnomax2 "# of dept applied in 2nd round"



**replace high school GPA missing with 進入二階的gpa資訊
egen gpamin=min(hsch_gpa), by(year id)
gen gpa=hsch_gpa
replace gpa=gpamin if hsch_gpa==.
replace gpa=. if hsch_gpa==0 


gen stem=0
label var stem "department in STEM colleges"
replace stem=1 if college ==1 |college==3 | college==6 |college==7|college==8|college==11|college==11|college==12

**筆試比重分四組
cap drop writtenp4c 
recode writtenp (0=0) (.15/.25=1 ) (.3/.45=2) (.5/.9=3), gen (writtenp4c)



sort dept outcome score 
*list dept outcome score No, sepby(dept)
label var score "甄選總成績"

*學測總成績系內排序
bysort year dept: egen gsatrank= rank(gsat)  
label var gsatrank "gsat rank order within the department (with ties)"



gen  hschrank1 = hschrank

**replace 中正預校 hschrank
replace hschrank=0 if 就讀高中 =="中正國防幹部預備學校"



***convert hschrank to actual rank (ranked by average of two years hschrank )
preserve
sort year 學校代碼 
keep year 學校代碼 hschrank 
*keep one case from each school for each year
gen schoolid= 學校代碼 
replace hschrank=. if schoolid==schoolid[_n-1]
drop if hschrank==. 
sort schoolid year
list in 1/100, sepby(schoolid)

*take the two year average of hschrank
collapse (mean) hschrank_m = hschrank, by(學校代碼) 
egen ranksch= rank(hschrank_m) , field
label var ranksch "rank order of high school performance by two-years average"


label var ranksch "high school rank"

sort 學校代碼
save hschrank.dta, replace
restore 

merge m:1 學校代碼 using hschrank.dta,  
**************

drop _merge 

**the following commands do not have any effect
preserve
collapse (first)同級分超額篩選科目 , by(dept)
sort dept
save compare_subjects.dta, replace
restore

merge m:1 dept using compare_subjects.dta, update
drop _merge
replace 同級分超額篩選科目 = "英數A自" if 同級分超額篩選科目 ==""
*****************the following command produce the same var as obsnomax********
sort id dept
bysort id: gen ntuapp=[_n-1]+1
egen ntuappno=max(ntuapp), by (id)
label var ntuappno "no of department applied at NTU"

**correction:程式有誤, 先執行keep if dsource==3 才encode 導致lowinc的編碼不對
encode 是否低收入戶, gen(lowinc)
recode lowinc (1 2=0)( 3 4=1)
label define lowinc 1 "中低收入戶" 0 "一般家庭", replace



keep if dsource ==3  /*只保留進二階樣本*/




**按照科系、學測成績、比序科目1、比序科目2、比序科目3、比序科目4 , 5, 6  將資料由大排至小
gsort +year +dept -gsat  -rank1 -rank2 -rank3 -rank4 -rank5 -rank6 
**按照學測成績及同分比序規則，創造系內排名(若仍同分，則隨機亂排)
bysort year dept: gen cfrank = _n

**創造各系正取人數名額
bysort year dept: egen totadmit = total(admitted)

**create counterfactual admission
*cfadmit =1 若系內排序小於錄取名額
gen cfadmit =  cfrank <= totadmit
label var cfadmit "admitted by using GSAT only (counterfactual)"
***list test score to adjut cfrank by hand
list year dept gsat rank1 rank2 rank3 rank4 rank5 rank6 cfrank totadmit cfadmit outcome, sepby(dept)

bysort year:tab cfadmit admitted


bysort  female: tab admitted cfadmit  if dsource ==3 & penexam==0, cell

gen admitexp=0 if cfadmit==0 & admitted==0

replace admitexp=3 if cfadmit==1 & admitted==1

replace admitexp=1 if cfadmit==1 & admitted==0

replace admitexp=2 if cfadmit==0 & admitted==1

label define admitexp 0 "always out" 3 "always in" 2 "switch in" 1 "switch out"

label val admitexp admitexp 


gen admitswitch=0 if admitexp==1
replace admitswitch=1 if admitexp==2

gen lnhousing10=ln(housing*10)


*****************************
**correction, previous lowinc exclude 中低收入
gen disadvantage=0
replace disadvantage=1 if (minority==1 |minority==2|lowinc==1 )
label var disadvantage "minority/remote area/low income"


cap drop penscore100
gen penscore100=(pen1*written1+pen2*written2+pen3*written3)/(written1+written2+written3)
replace penscore100=(pen1*.05+pen2*.05+pen3*.20+pen4*.20)/.50 if dept==1242|dept==1252 /*醫學系*/
replace penscore100=(pen1*written1+pen2*written2+pen3*.125+pen4*.125)/0.6 if dept==1262 /*牙醫學系*/
replace penscore100=. if penexam==0 

*********************


cap drop writtenp3c 



cap drop writtenp4c2 
recode writtenp (0=0) (0.01/0.2=1) (.25/.4=2 ) (.45/.9=3), gen (writtenp4c2)

cap drop writtenp3c 
recode writtenp (0=0) (0.01/0.3=1) (0.31/.9=2 ), gen (writtenp3c)

label define written3c 0 "0" 1 "1~30%" 2 ">30%" , replace 
label val writtenp3c written3c 

mi set mlong
set seed 1111
mi register impute gpa
mi  impute mvn gpa = female i.disadvantage  lnhousingp ranksch zipcollegep25 private exam100 i.dept i.outcome   i.obsnomax  score i.obsnomax2 i.year, add(20)


save ntu_mi3.dta, replace 




*****************************************************************
****Study: how admission methods affect girls in STEM  
*****************************************************************
clear
*cd "e:\ntu\work"
cd "C:\Users\Wei-hsin Yu\Box\PAPERS\publication\Elite college in Taiwan\Study 2"
use ntu_mi3.dta 





**Table 1 descriptives 
sum i.admitswitch 審查成績平均 口試成績平均 penscore100 if _mi_m==0
bysort female: sum 審查成績平均 if 審查成績平均>0 & _mi_m==0 
bysort female: sum 口試成績平均 if 口試成績平均 >0 & _mi_m==0 
bysort female: sum  penscore100 if  penscore100 >0 & _mi_m==0 
bysort female: sum admitted female disadvantage i.retake lnhousing10 zipcollegep25 ranksch private gpa page i.obsnomax i.year exam100 if _mi_m==0 

tab admitexp if _mi_m==0

**Table 2

est clear
mi estimate: areg 審查成績平均  i.female i.year  if 審查成績平均>0 ,  ab(dept) cluster (id)
est store m1
mi estimate: areg 審查成績平均 i.female disadvantage i.retake lnhousing10 zipcollegep25 ranksch private gpa page exam100 i.obsnomax i.year  if 審查成績平均>0 ,  ab(dept) cluster (id)
est store m2
mi estimate: areg 審查成績平均 i.female  i.female##i.stem disadvantage i.retake lnhousing10 zipcollegep25 ranksch private gpa page exam100 i.obsnomax i.year exam100 if 審查成績平均>0 ,  ab(dept) cluster (id) 
est store m3
mi estimate: areg 審查成績平均 i.female i.female##c.t_malep disadvantage i.retake lnhousing10 zipcollegep25 ranksch private gpa page exam100 i.obsnomax i.year exam100  if 審查成績平均>0 ,  ab(dept) cluster (id) 
est store m4

mi estimate: areg 審查成績平均 i.female i.female##c.s_malep disadvantage i.retake lnhousing10 zipcollegep25 ranksch private gpa page exam100 i.obsnomax i.year exam100  if 審查成績平均>0 ,  ab(dept) cluster (id) 
est store m5

*mi estimate, saving(dosfile, replace) esample(dossample) : areg 審查成績平均 i.female##c.s_malep disadvantage i.retake lnhousing10 zipcollegep25 ranksch private gpa page exam100 i.obsnomax i.year  i.female##c.s_malep if 審查成績平均>0   ,  ab(dept) cluster (id) 
*mimrgns using dosfile, at(s_malep=(0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9) female=(0 1)) esample(dossample) cmdmargins
*marginsplot, noci 

*mi estimate : areg 審查成績平均 i.female##c.s_malep  i.female##c.s_malep i.female disadvantage i.retake lnhousing10 zipcollegep25 ranksch private gpa page exam100 i.obsnomax i.year  if 審查成績平均>0 ,  ab(dept) cluster (id) 
etable, estimates(m1 m2 m3 m4 ) mstat(N) stars(.1 "+" .05 "*" .01 "**" .001 "***") title(Table 3: Department Fixed Effects Models Predicting Dossier Scores) note(Note: Model results presented here are based on estimations from 20 imputed datasets. All models include department fixed effects and are clustered by applicant. Numbers in parentheses are clustered standard errors.) export(table.xlsx, sheet(table3, replace)  modify )
 
**Table 3
est clear
mi estimate: areg 口試成績平均 i.female  i.year  if 口試成績平均>0 & oralexam==1 ,  ab(dept) cluster (id)
est store m1
mi estimate: areg 口試成績平均 i.female disadvantage i.retake lnhousing10 zipcollegep25 ranksch private gpa page exam100 i.obsnomax i.year  if 口試成績平均>0 & oralexam==1 ,  ab(dept) cluster (id)
est store m2 
mi estimate: areg 口試成績平均 i.female i.female##i.stem disadvantage i.retake lnhousing10 zipcollegep25 ranksch private gpa page exam100 i.obsnomax i.year   if 口試成績平均>0 & oralexam==1,  ab(dept) cluster (id) 
est store m3
mi estimate: areg 口試成績平均 i.female i.female##c.t_malep disadvantage i.retake lnhousing10 zipcollegep25 ranksch private gpa page exam100 i.obsnomax i.year   if 口試成績平均>0 & oralexam==1,  ab(dept) cluster (id) 
est store m4
*mi estimate, saving (oralfile, replace) esample(oralsample2): areg 口試成績平均 i.female disadvantage i.retake lnhousing10 zipcollegep25 ranksch private gpa page exam100 i.obsnomax i.year exam100 i.female##c.s_malep if 口試成績平均>0 & oralexam==1,  ab(dept) cluster (id)

*mimrgns using oralfile, at(female=(1 0) s_malep=(0 0.25 0.5 0.75 1)) esample(oralsample)
 
mi estimate: areg 口試成績平均 i.female  i.female##c.s_malep disadvantage i.retake lnhousing10 zipcollegep25 ranksch private gpa page exam100 i.obsnomax i.year  if 口試成績平均>0 & oralexam==1,  ab(dept) cluster (id) 
est store m5
*mi estimate : areg 口試成績平均 i.female disadvantage i.retake lnhousing10 zipcollegep25 ranksch private gpa page exam100 i.obsnomax i.year i.female##c.t_malep  i.female##c.s_malep if 口試成績平均>0 & oralp==1,  ab(dept) cluster (id) 

etable, estimates(m1 m2 m3 m4 ) mstat(N) stars(.1 "+" .05 "*" .01 "**" .001 "***") title(Table 4: Department Fixed Effects Models Predicting Interview Scores) note(Note: Model results presented here are based on estimations from 20 imputed datasets. All models include department fixed effects and are clustered by applicant. Numbers in parentheses are clustered standard errors. )  export(table.xlsx, sheet(table4, replace)  modify )

**Table 4 
est clear
mi estimate: areg penscore100 i.female  i.year  if penscore100>0 & penexam==1,  ab(dept) cluster (id)
est store m1

mi estimate: areg penscore100 i.female disadvantage i.retake lnhousing10 zipcollegep25 ranksch private gpa page exam100 i.obsnomax i.year  if penscore100>0 & penexam==1,  ab(dept) cluster (id)
est store m2

mi estimate  : areg penscore100 i.female  i.female##i.stem   disadvantage i.retake lnhousing10 zipcollegep25 ranksch private gpa page exam100 i.obsnomax i.year if penscore100>0 & penexam==1,  ab(dept) cluster (id) 
est store m3

mi estimate  : areg penscore100 i.female i.female##c.t_malep  disadvantage i.retake lnhousing10 zipcollegep25 ranksch private gpa page exam100 i.obsnomax i.year   if penscore100>0 & penexam==1,  ab(dept) cluster (id) 
est store m4

mi estimate: areg penscore100 i.female i.female##c.s_malep  disadvantage i.retake lnhousing10 zipcollegep25 ranksch private gpa page exam100 i.obsnomax i.year  if penscore100>0 & penexam==1,  ab(dept) cluster (id) 
est store m5


etable, estimates(m1 m2 m3 m4 ) mstat(N) stars(.1 "+" .05 "*" .01 "**" .001 "***") export(table.xlsx, sheet(table5, replace)  modify )  title(Table 5: Department Fixed Effects Models Predicting Major-Specific Test Scores) note(Note: Model results presented here are based on estimations from 20 imputed datasets. All models include department fixed effects and are clustered by applicant. Numbers in parentheses are clustered standard errors. )
**Table 5


est clear
mi estimate: areg admitswitch female ,  ab(dept) cluster (id)
est store m1
mi estimate: areg admitswitch female disadvantage retake lnhousing10 zipcollegep25 ranksch private gpa page i.obsnomax i.year,  ab(dept) cluster (id)
est store m2 
mi estimate: areg  admitswitch female i.female##i.stem  disadvantage retake lnhousing10 zipcollegep25 ranksch private gpa page i.obsnomax i.year, ab(dept) cluster (id)
est store m3
mi estimate: areg admitswitch female i.female##c.t_malep disadvantage retake lnhousing10 zipcollegep25 ranksch private gpa page i.obsnomax i.year , ab(dept) cluster (id)
est store m4
mi estimate: areg admitswitch female i.female##c.s_malep disadvantage retake lnhousing10 zipcollegep25 ranksch private gpa page i.obsnomax  i.year , ab(dept) cluster (id)


est store m5
etable, estimates(m1 m2 m3 m4 m5) mstat(N) stars(.1 "+" .05 "*" .01 "**" .001 "***") column(index) title(Table 2: Department Fixed Effect Models Predicting Positive Instead of Negative Changes in Admission Outcomes) note(Note: Model results presented here are based on estimations from 20 imputed datasets. All models include department fixed effects and are clustered by applicant. Numbers in parentheses are clustered standard errors. )  export(table.xlsx, sheet(table2, replace)     modify  )  replace
***Table 6



gen fs_maleppyes=female*s_malep if female==1 & penexam==1
replace fs_maleppyes=0 if fs_maleppyes==. 

label var fs_maleppyes "female*s_malep*penexam=1"
gen  fs_maleppno=female*s_malep if female==1 & penexam==0
replace fs_maleppno=0 if fs_maleppno==.  
label var fs_maleppyes "female*s_malep*penexam=0"

*mi estimate: areg admitswitch female disadvantage retake lnhousing10 zipcollegep25 ranksch private gpa page i.obsnomax  i.female##c.s_malep i.female##i.oralexam i.female##i.penexam, ab(dept) cluster (id)
*mi estimate: areg admitswitch female disadvantage retake lnhousing10 zipcollegep25 ranksch private gpa page i.obsnomax  i.female##c.s_malep i.writtenp3c i.female#ib0.writtenp3c , ab(dept) cluster (id)
**writtenp not significantly different between female*2.writtenp3c and female*3.writtenp3c even thought it looks that the former is larger; bottom line is that it is not the higher the proportion the worse for women 

*mi estimate: areg admitswitch female disadvantage retake lnhousing10 zipcollegep25 ranksch private gpa page i.obsnomax i.female c.s_malep i.penexam  c.fs_maleppyes c.fs_maleppno  , ab(dept) cluster (id)
*mi estimate  (diff: _b[fs_maleppyes]-_b[fs_maleppno]), saving(newest): areg admitted  female disadvantage retake lnhousing10 zipcollegep25 ranksch private gpa page i.obsnomax  i.female i.penexam c.s_malep c.fs_maleppyes c.fs_maleppno  ,   ab(dept) cluster (id)
**it is the sex ratio of the department plus the exam that makes it worse
est clear
mi estimate: areg admitted female  i.female##c.s_malep  disadvantage retake lnhousing10 zipcollegep25 ranksch private gpa page exam100 i.obsnomax i.year,   ab(dept) cluster (id)
est store m1
mi estimate: areg admitted female  i.female##c.s_malep i.female##i.oralexam i.female##i.penexam disadvantage retake lnhousing10 zipcollegep25 ranksch private gpa page exam100 i.obsnomax i.year,   ab(dept) cluster (id)
est store m2
mi estimate: areg admitted female i.female##c.s_malep i.female##c.oralp i.female##c.writtenp  i.female##c.reviewp disadvantage retake lnhousing10 zipcollegep25 ranksch private gpa page exam100 i.obsnomax i.year  ,   ab(dept) cluster (id)
est store m3
mi estimate: areg admitted female i.female##c.s_malep i.writtenp3c i.female#ib0.writtenp3c  disadvantage retake lnhousing10 zipcollegep25 ranksch private gpa page exam100 i.obsnomax  i.year , ab(dept) cluster (id)
est store m4
mi estimate: areg admitted female  c.s_malep i.penexam  c.fs_maleppyes c.fs_maleppno disadvantage retake lnhousing10 zipcollegep25 ranksch private gpa page exam100 i.obsnomax i.year  , ab(dept) cluster (id)
est store m5
*mi estimate  (diff: _b[fs_maleppyes]-_b[fs_maleppno]), saving(newest): areg admitted  female disadvantage retake lnhousing10 zipcollegep25 ranksch private gpa page i.obsnomax  i.female i.penexam c.s_malep c.fs_maleppyes c.fs_maleppno  ,   ab(dept) cluster (id)

etable, estimates(m1 m2 m3 m4 m5) mstat(N) stars(.1 "+" .05 "*" .01 "**" .001 "***")  title(Table 6: Department Fixed Effects Models Predicting Being Admitted or Not ) note(Note: Model results presented here are based on estimations from 20 imputed datasets. The models include department fixed effects and are clustered by applicant. Numbers in parentheses are clustered standard errors. All models control for disadvantaged status, ronin status, log family housing price, concentration of college graduates in residential area, high school ranking, high school being private, high school grade average, dossier length, and the number of the applications submitted to NTU.    ) export(table.xlsx, sheet(table6, replace)  modify )




**Figure 2


*sum i.admitswitch 審查成績平均 口試成績平均 penscore100 if _mi_m==0

bysort female stem: sum exam100 gpa if _mi_m==0 
bysort female stem: sum 審查成績平均 if 審查成績平均>0 & _mi_m==0 
bysort female stem: sum 口試成績平均 if 口試成績平均 >0 & _mi_m==0 
bysort female stem : sum  penscore100 if  penscore100 >0 & _mi_m==0 


bysort female stem: sum admitted female disadvantage i.retake lnhousing10 zipcollegep25 ranksch private gpa page i.obsnomax i.year exam100 if _mi_m==0 

tab admitexp if _mi_m==0


***Figure 3 (calculate gender differences after the margin commands )
mi convert flong 
mi estimate, saving(dosfile, replace) esample(dossample) : areg 審查成績平均 i.female##c.s_malep disadvantage i.retake lnhousing10 zipcollegep25 ranksch private gpa page exam100 i.obsnomax i.year  i.female##c.s_malep if 審查成績平均>0   ,  ab(dept) cluster (id) 
mimrgns using dosfile, at(s_malep=(0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9) female=(0 1)) esample(dossample) cmdmargins

exit 

mi estimate, saving (orfile, replace) esample(orsample): areg 口試成績平均 i.female i.female##c.t_malep disadvantage i.retake lnhousing10 zipcollegep25 ranksch private gpa page exam100 i.obsnomax i.year   if 口試成績平均>0 & oralexam==1,  ab(dept) cluster (id) 
mimrgns using orfile, at(t_malep=(0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9) female=(0 1)) esample(orsample) cmdmargins
 

exit 

mi estimate, saving (penfile, replace) esample(pensample): areg penscore100 i.female i.female##c.s_malep  disadvantage i.retake lnhousing10 zipcollegep25 ranksch private gpa page exam100 i.obsnomax i.year  if penscore100>0 & penexam==1,  ab(dept) cluster (id) 
mimrgns using penfile, at(s_malep=(0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9) female=(0 1)) esample(pensample) cmdmargins
 

exit 

mi estimate, saving (swfile, replace) esample(swsample): areg admitswitch i.female##c.s_malep disadvantage retake lnhousing10 zipcollegep25 ranksch private gpa page i.obsnomax  i.year , ab(dept) cluster (id)
mimrgns using swfile, at(s_malep=(0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9) female=(0 1)) esample(swsample) cmdmargins


 



*******Table S1
est clear
mi estimate: areg 審查成績平均 i.female  i.year  if 審查成績平均>0 ,  ab(dept) cluster (id)
est store m1
mi estimate: areg 審查成績平均 i.female disadvantage i.retake lnhousing10 zipcollegep25 ranksch private  exam100 i.obsnomax i.year  if 審查成績平均>0 ,  ab(dept) cluster (id)
est store m2
mi estimate: areg 審查成績平均 i.female  i.female##i.stem disadvantage i.retake lnhousing10 zipcollegep25 ranksch private  exam100 i.obsnomax i.year exam100 if 審查成績平均>0 ,  ab(dept) cluster (id) 
est store m3
mi estimate: areg 審查成績平均 i.female i.female##c.t_malep disadvantage i.retake lnhousing10 zipcollegep25 ranksch private  exam100 i.obsnomax i.year exam100  if 審查成績平均>0 ,  ab(dept) cluster (id) 
est store m4

mi estimate: areg 審查成績平均 i.female i.female##c.s_malep disadvantage i.retake lnhousing10 zipcollegep25 ranksch private  exam100 i.obsnomax i.year exam100  if 審查成績平均>0 ,  ab(dept) cluster (id) 
est store m5

etable, estimates(m1 m2 m3 m4 m5) mstat(N) stars(.1 "+" .05 "*" .01 "**" .001 "***") title(Table 3: Department Fixed Effects Models Predicting Dossier Scores) note(Note: Model results presented here are based on estimations from 20 imputed datasets. All models include department fixed effects and are clustered by applicant. Numbers in parentheses are clustered standard errors.) export(table.xlsx, sheet(tablea1, replace)  modify )


***Table S5
est clear
mi estimate: areg exam100  i.female  i.year  if exam100>0 ,  ab(dept) cluster (id)
est store m1
mi estimate: areg exam100  i.female disadvantage i.retake lnhousing10 zipcollegep25 ranksch private  gpa page i.obsnomax i.year  if exam100>0 ,  ab(dept) cluster (id)
est store m2
mi estimate: areg exam100 i.female  i.female##i.stem disadvantage i.retake lnhousing10 zipcollegep25 ranksch private  gpa page i.obsnomax i.year if exam100>0 ,  ab(dept) cluster (id) 
est store m3
mi estimate: areg exam100 i.female i.female##c.t_malep disadvantage i.retake lnhousing10 zipcollegep25 ranksch private  gpa page i.obsnomax i.year   if exam100>0 ,  ab(dept) cluster (id) 
est store m4
mi estimate: areg exam100  i.female i.female##c.s_malep disadvantage i.retake lnhousing10 zipcollegep25 ranksch private  gpa page i.obsnomax i.year  if exam100>0 ,  ab(dept) cluster (id) 
est store m5

etable, estimates(m1 m2 m3 m4 m5) mstat(N) stars(.1 "+" .05 "*" .01 "**" .001 "***") title(Table 3: Department Fixed Effects Models Predicting Dossier Scores) note(Note: Model results presented here are based on estimations from 20 imputed datasets. All models include department fixed effects and are clustered by applicant. Numbers in parentheses are clustered standard errors.) export(table.xlsx, sheet(tablea2, replace)  modify )

***Figure A2
gen mstem=0
replace mstem=1 if stem==1 & s_malep>0.6

bysort female mstem: sum exam100 gpa if _mi_m==0 
bysort female mstem: sum 審查成績平均 if 審查成績平均>0 & _mi_m==0 
bysort female mstem: sum 口試成績平均 if 口試成績平均 >0 & _mi_m==0 
bysort female mstem : sum  penscore100 if  penscore100 >0 & _mi_m==0 
bysort female mstem: sum obsnomax if _mi_m==0

bysort female mstem: sum admitted female disadvantage i.retake lnhousing10 zipcollegep25 ranksch private gpa page i.obsnomax i.year exam100 if _mi_m==0 

tab admitexp if _mi_m==0